<template>
  <div class="dashboard-container">
    <div style="margin:15px">
      <el-button type="primary" @click="toAdd({message:''})">新增</el-button>
    </div>
    
    <el-table
      ref="multipleTable"
      :data="tableData"
      tooltip-effect="dark"
      style="width: 98%;margin:15px auto;"
      
    >
      <!--@selection-change="handleSelectionChange" <el-table-column type="selection" width="55"> </el-table-column> -->
      <el-table-column prop="message" label="信息">
      </el-table-column>
      <el-table-column prop="updateTime" label="时间">
      </el-table-column>
      <el-table-column fixed="right" label="操作">
        <template slot-scope="scope">
          <el-button type="text" size="small" @click="handleDelete(scope.row)">删除</el-button>
        </template>（
      </el-table-column>
    </el-table>
    <el-dialog title="修改" :visible.sync="editVisible">
      <el-form ref="dialogFrom" :model="dialogFrom" label-width="80px">
          <el-form-item label="内容">
            <el-input v-model="dialogFrom.message"></el-input>
          </el-form-item>
        </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="editVisible = false">取 消</el-button>
        <el-button type="primary" @click="handleSure('dialogFrom')"
          >确 定</el-button
        >
      </div>
    </el-dialog>
  </div>
</template>

<script>
import { mapGetters } from "vuex";
import { userUpdate } from "@/api/info";
import mixin from '@/utils/mixin';
export default {
  name: "公告管理",
  mixins: [mixin],
  computed: {
    ...mapGetters(["name"]),
  },
  data() {
    return {
      tableData: [],
      queryUrl: "/inform/all",
      delUrl: "/inform",
      batchDelUrl: "/inform/delete/list",
      editUrl: "/inform/update",
      addUrl: "/inform/publish",
      dialogFrom: {},
      updatemethod: 'put',
      querymethod: 'get'
    };
  },
  created(){
    this.getAllTag()
  },
  methods:{
    handleimageUrlSuccess(res, file) {
      console.log(res, file)
      this.dialogFrom.imageUrl = URL.createObjectURL(file.raw);
    },
    beforeimageUrlUpload(file) {
      const isLt3M = file.size / 1024 / 1024 < 3;

      if (!isLt3M) {
        this.$message.error("上传头像图片大小不能超过 3MB!");
      }
      return isLt3M;
    },
    changeTag(val){
      console.log(val,'tag')
      let obj = this.tagList.find(item=> item.id == val)
      this.dialogFrom.tagTitle = obj.tagTitle
    },
    onSubmit(){
      userUpdate(this.form).then((res) => {
        this.$message.success(res.msg);
        Cookies.get("userInfo", this.form);
        this.$store.commit("SET_USERINFO", this.form);
        this.$store.commit("SET_NAME", this.form.username);
        this.$store.commit("SET_imageUrl", this.form.imageUrl);
        this.userInfo = JSON.parse(JSON.stringify(this.form));
      });
    }
  }
};
</script>

<style lang="scss" scoped>
.dashboard {
  &-container {
    width: 100vw;
    overflow: hidden;
    .boxW {
      width: 80vw;
      margin: 15px auto;
    }
    .title {
      display: flex;

      display: flex;
      justify-content: space-between;
      align-items: center;
      div {
        color: rgb(136, 78, 34);
      }
    }
    .module {
      display: flex;
      justify-content: space-between;
      img {
        width: 288px;
      }
    }
  }
  &-text {
    font-size: 30px;
    line-height: 46px;
  }
}
</style>
